<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>用户管理</title>
    <link href="../../css/mine.css" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script type="text/javascript">
            function deleteBatch() {
                document.getElementById("method").value="deleteBatch"
                // document.getElementById("form").submit()
                document.forms[1].submit()
            }
            function exports() {
                document.getElementById("method").value="exports"
                // document.getElementById("form").submit()
                document.forms[1].submit()
            }

    </script>
</head>
<body>
<style>
    .tr_color {
        background-color: #9F88FF
    }
</style>
<div class="div_head">
            <span>
                <span style="float: left;">当前位置是：系统管理-》用户管理</span>
                <span style="float: right; margin-right: 8px; font-weight: bold;">
                    <span onclick="exports()" color="blue" style="cursor: pointer;">【导出数据】</span>>
                    <a style="text-decoration: none;" href="/resource/demo2/getAllDept">【添加】</a>
                    <span onclick="deleteBatch()" color="blue" style="cursor: pointer;">【删除】</span>>
                </span>
            </span>
</div>
<div></div>
<div class="div_search">
            <span>
                <form action="/resource/demo2/getusers" method="post">
                     姓名：
					<input type="text" name="username" value="${uname}"/>
					 角色: 
					<input type="text" name="rolename" value="${rname}"/>
					 所属部门: 
					<input type="text" name="deptname" value="${dname}"/>

                    <input value="查询" type="submit"/>
                </form>
            </span>
</div>
<div style="font-size: 13px; margin: 10px 5px;">
    <form id="form" action="/resource/demo2/deleteBatch" method="post">
    <table class="table_a" border="1" width="100%">
        <input type="hidden" name="method" id="method">
        <tbody>
        <tr style="font-weight: bold;">
            <td width="40px;">序号</td>
            <td width="30px;"><input type="checkbox" name="empId" id="all" onclick="allChoice(choice)"/></td>
            <td width="80px;">账号</td>
            <td width="80px;">姓名</td>
            <td>角色</td>
            <td width="100px;">所属部门</td>
            <td align="center" width="200px;">操作</td>
        </tr>

        <c:forEach items="${pageInfo.list}" varStatus="s" var="emp">
            <tr id="product1">
                <td>${emp.id}</td>
                <td><input type="checkbox" id="choice" name="empId" value="${emp.id}"/></td>
                <td>${emp.loginname}</td>
                <td><a href="view.jsp">${emp.username}</a></td>
                <td>${emp.role.rname}</td>
                <td>${emp.dept.deptname}</td>
                <td>
                    <a href="/resource/demo2/findOneUser?id=${emp.id}">修改</a>
                    <a href="/resource/demo2/deleteById?id=${emp.id}">删除</a>
                </td>
            </tr>
        </c:forEach>

        <tr>
            <td colspan="20" style="text-align: center;">
                <a style="text-decoration: none;" href="/resource/demo2/getusers?username=${uname}&rolename=${rname}&deptname=${dname}">
                    首页
                </a>
                <a style="text-decoration: none;" href="/resource/demo2/getusers?page=${pageInfo.prePage==0?1:pageInfo.prePage}&username=${uname}&rolename=${rname}&deptname=${dname}">
                    上一页
                </a>
                <c:forEach var="s"  begin="1" end="${pageInfo.pages}" >
                    <a style="text-decoration: none;" href="/resource/demo2/getusers?page=${s}&username=${uname}&rolename=${rname}&deptname=${dname}">
                        ${s}
                    </a>
                </c:forEach>
                <a style="text-decoration: none;" href="/resource/demo2/getusers?page=${pageInfo.nextPage==0?pageInfo.pages:pageInfo.nextPage}&username=${uname}&rolename=${rname}&deptname=${dname}">
                    下一页
                </a>
                <a style="text-decoration: none;" href="/resource/demo2/getusers?page=${pageInfo.pages}&username=${uname}&rolename=${rname}&deptname=${dname}">
                    尾页
                </a>
                共${pageInfo.total}条 第${pageInfo.pageNum}页/共${pageInfo.pages}页
            </td>
        </tr>
        </tbody>
    </table>
    </form>
</div>
</body>
<script type="text/javascript">
    function allChoice(choice) {
        var allChoice = document.getElementById("all")
        var choice = document.getElementsByName(choice)
        alert("获取是否选择")
        if(allChoice.checked){

            for(var i=0;i<choice.length;i++){
                choice[i].checked = true
                alert("全选")
            }
        }else{

            for(var i=0;i<choice.length;i++){
                choice[i].checked = false
                alert("全不选")
            }
        }
    }
</script>
</html>